import Vue from 'vue'
import App from './App'
import http from 'api/http.js'
import url from 'api/api.js'

Vue.prototype.$http = http
Vue.prototype.$url = url

Vue.config.productionTip = false

const msg = (title, duration = 4000, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

const gotoType = (type, url) => {
	if (type == "tab") { //跳转tab页面的方式
		uni.switchTab({
			url: url
		})
	} else if (type == "to") { //正常页面跳转
		uni.navigateTo({
			url: url,
			animationDuration: 500,
			animationType: "slide-in-right"
		})
	} else if (type == "back") {
		uni.navigateBack({
			animationType: "slide-out-right",
			animationDuration: 500,
		})
	} else if (type == "rto") {
		uni.redirectTo({
			url: url
		})
	}
}
Vue.prototype.$api ={
	gotoType,
	msg
}
App.mpType = 'app'

const app = new Vue({
	...App
})
app.$mount()
